<link rel="stylesheet" type="text/css" href="{:getRootUrl()}Addons/CheckIn/Static/css/check.css">

<div class="checkdiv">
    <div class="row">
        <div class="col-xs-4 text-center" style="margin-left: 19px;">
            <img class="ico_calendar" src="{:getRootUrl()}Addons/CheckIn/Static/images/calendar.png">
            <php>if(!$check){</php>
            <a href="javascript:void(0)" data-role="do_checkin" class="btn-sign">签到</a>
            <php>}else{</php>
            <a href="javascript:void(0)" class="btn-sign">已签</a>
            <php>}</php>
        </div>

        <div class="col-xs-3  text-center">
            {$week}
        </div>
        <div>
            {$day}
        </div>

    </div>
</div>
        <div class="check-tab">
            <div class="col-xs-4 text-center active" data-role="change_rank" data-type="today" >今日抢签</div>
            <div class="col-xs-4 text-center" data-role="change_rank" data-type="con">连签</div>
            <div class="col-xs-4 text-center" data-role="change_rank" data-type="total">累签</div>
        </div>
        <div  class="clearfix"></div>
<div id="rank-list" style="margin-bottom: 15px;">
    {$html}
</div>

<script>
$(function(){
    do_checkin();

    $('[data-role="change_rank"]').click(function(){
        var $this = $(this);
        var type = $this.attr('data-type')
        $.post("{:addons_url('CheckIn://CheckIn/getRank')}", {type:type}, function (res) {
            if (res.status) {
                $('#rank-list').html(res.html);
                $('[data-role="change_rank"]').removeClass('active');
                $this.addClass('active');
                follower.bind_follow();
                ucard()
            }
        });
    })

})



    var do_checkin = function () {
        $('[data-role="do_checkin"]').click(function () {
            var $this = $(this);
            $.post("{:addons_url('CheckIn://CheckIn/doCheckIn')}", {}, function (res) {
                if (res.status) {
                    $this.replaceWith('<a href="javascript:void(0)" class="btn-sign">已签</a>');
                    $('.check-tab').find('.active').click();
                    toast.success(res.info);
                } else {
                    handleAjax(res);
                    setTimeout(function () {
                        location.reload();
                    }, 1500);
                }
                //location.reload();
            });


        })
    }


</script>
